//
//  MqTInfoCommentableViewCell.m
//  Meiqi
//
//  Created by 王郑 on 16/1/18.
//  Copyright © 2016年 KFC. All rights reserved.
//

#import "MqTInfoCommentableViewCell.h"
@implementation MqTInfoCommentableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        _headImageV = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _headImageV.frame = CGRectMake(10 * kWidthBase, 20 * kHeightBase, 40*kWidthBase, 40*kHeightBase);
       // _headImageV.backgroundColor = [UIColor redColor];
        _headImageV.layer.cornerRadius = 20*kWidthBase;
        _headImageV.layer.masksToBounds = YES;
        [self.contentView addSubview:_headImageV];
        
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_headImageV.right + 5 * kWidthBase, _headImageV.top, 150 * kWidthBase ,20 * kHeightBase)];
       // _nameLabel.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_nameLabel];
        
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_nameLabel.left, _nameLabel.bottom, 100*kWidthBase, 20*kHeightBase)];
        //_timeLabel.backgroundColor = [UIColor greenColor];
        _timeLabel.font = [UIFont systemFontOfSize:12];
        _timeLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_timeLabel];
        
        
        _zanNumLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - 50*kWidthBase, _nameLabel.top, 30*kWidthBase, _nameLabel.height)];
        //_zanNumLabel.backgroundColor = [UIColor redColor];
        _zanNumLabel.font = [UIFont systemFontOfSize:12];
        _zanNumLabel.textColor = [UIColor grayColor];
        _zanNumLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_zanNumLabel];
        
        _zanButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _zanButton.frame = CGRectMake(_zanNumLabel.left - 20*kWidthBase, _zanNumLabel.top, 20*kWidthBase, _zanNumLabel.height);
        [_zanButton setBackgroundImage:[UIImage imageNamed:@"info-zan"] forState:(UIControlStateNormal)];
        [self.contentView addSubview:_zanButton];
        [_zanButton addTarget:self action:@selector(zanAction:) forControlEvents:(UIControlEventTouchUpInside)];
        
        _commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(_timeLabel.left, _timeLabel.bottom + 10 * kHeightBase, (kScreenWidth - _timeLabel.left - 20 * kWidthBase), 50 * kHeightBase)];
       // _commentLabel.backgroundColor = [UIColor magentaColor];
        _commentLabel.font = [UIFont systemFontOfSize:14];
        _commentLabel.textColor  = [UIColor grayColor];
        _commentLabel.numberOfLines = 0;
        [self.contentView addSubview:_commentLabel];
        
        
        
        
        
    }
    
    
    return self;
}

- (void)setModel:(MqCommentModel *)model
{
    _model = model;
    [_headImageV sd_setImageWithURL:[NSURL URLWithString:@""] forState:(UIControlStateNormal) placeholderImage:[UIImage imageNamed:@"info-touxiang"]];
    _nameLabel.text = model.username;
    _timeLabel.text = model.saytime;
    _zanNumLabel.text = model.zcnum;
    _commentLabel.text = model.saytext;
    
    
    
}

- (void)zanAction:(UIButton *)button
{
    _zanNumLabel.text = @"+1";
    [_zanButton setBackgroundImage:[UIImage imageNamed:@"info-zan3"] forState:(UIControlStateNormal)];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
